package io;

import java.io.*;

public class CopyDemo2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("66a0f1473a0f4ae7850ac8607774eb03.jpg");
        FileOutputStream fos = new FileOutputStream("zq_lx2.jpg");
        long start = System.currentTimeMillis();
        byte[] data = new byte[1024*10];//10kb
        int len;
        while ((len =fis.read(data))!=-1){//每次读取10个kb并判断是否读取到了末尾
            fos.write(data,0,len);//

        }
        long end = System.currentTimeMillis();
        System.out.println("复制完毕"+"耗时:"+(end-start)+"ms");
        fis.close();
        fos.close();






























        /*
        long start = System.currentTimeMillis();
        byte[] data = new byte[1024*10];//10kb
        while (fis.read(data)!=-1){//每次读取10个kb并判断是否读取到了末尾
            fos.write(data);//一次写入10kb的字节

        }
        long end = System.currentTimeMillis();
        System.out.println("复制完毕"+"耗时:"+(end-start)+"ms");
        fis.close();
        fos.close();

         */

    }
}
